﻿/**
 * This is a part of MCServe, which is available under the Apache license 2.0.
 * With this code, you may do whatever you want as long as that is not in conflict with this license.
 * In addition, you should have a reference to the original project to include (http://mcserve.codeplex.com).
 * 
 * Author       : Lars Krämer ( Xe77a )
 * Website      : http://www.lkraemer.de
 * Project      : MCServe (http://mcserve.codeplex.com)
 * Copyright    : Copyright (c) 2013 lkraemer.de
 * License      : http://mcserve.codeplex.com/license
 * Description  : This is a part of the core functionality of the server
 */

using MCServeLib.Types;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;

namespace MCServeCore.Components
{
    public class ServerPaths
    {
        private Dictionary<MCServePaths, String> _Paths = new Dictionary<MCServePaths, String>();

        public ServerPaths()
        {
            Add(MCServePaths.FOLDER_LOGS, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\logs");
            Add(MCServePaths.FOLDER_PLUGINS, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\plugins");
            Add(MCServePaths.FOLDER_SETTINGS, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\settings");
            Add(MCServePaths.FOLDER_WORLDS, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\worlds");
            Add(MCServePaths.FOLDER_DATABASE, Get(MCServePaths.FOLDER_SETTINGS) + "\\data");

            Add(MCServePaths.SETTINGS, Get(MCServePaths.FOLDER_SETTINGS) + "\\server.properties");

            Add(MCServePaths.LIST_BANNED_IPS, Get(MCServePaths.FOLDER_SETTINGS) + "\\banned-ips.json");
            Add(MCServePaths.LIST_BANNED_PLAYERS, Get(MCServePaths.FOLDER_SETTINGS) + "\\banned-players.json");
            Add(MCServePaths.LIST_OPS, Get(MCServePaths.FOLDER_SETTINGS) + "\\ops.json");
            Add(MCServePaths.LIST_WHITELIST, Get(MCServePaths.FOLDER_SETTINGS) + "\\white-list.json");

            Add(MCServePaths.LOG_SERVER, Get(MCServePaths.FOLDER_LOGS) + "\\server.log");
            Add(MCServePaths.LOG_MESSAGES, Get(MCServePaths.FOLDER_LOGS) + "\\messages.log");
            Add(MCServePaths.LOG_WARNING, Get(MCServePaths.FOLDER_LOGS) + "\\warning.log");
            Add(MCServePaths.LOG_ERRORS, Get(MCServePaths.FOLDER_LOGS) + "\\errors.log");
        }

        public void Add(MCServePaths PathType, String Path)
        {
            _Paths.Add(PathType, Path);
        }

        public String Get(MCServePaths PathType)
        {
            return _Paths[PathType];
        }
    }
}